/*
 * proc/mhn.h - processor specific defines
 *
 * Copyright (C) 2001  Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
 * Copyright (C) 2003  Abraham van der Merwe <abz@4dllc.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef BLOB_PXA_PROC_H
#define BLOB_PXA_PROC_H

#define io_p2v(x) (x)
#define io_v2p(x) (x)

#ifndef __ASSEMBLY__

#define __REG(x)	(*((volatile u32 *)io_p2v(x)))

#define __REG2(x,y)	\
	( __builtin_constant_p(y) ? (__REG((x) + (y))) \
				  : (*(volatile u32 *)((u32)&__REG(x) + (y))) )

# define __PREG(x)	(io_v2p((u32)&(x)))

#else

#define __REG(x)	io_p2v(x)
#define __PREG(x)	io_v2p(x)

#endif


#define __ASM_ARCH_HARDWARE_H
// TODO
// Some Patches by Adrian van der Merwe didn't make it yet into Russels/Nico's
// Linux patches, so for now we use our local pxa-regs.h file
//#include <asm-arm/arch-pxa/pxa-regs.h>
#include <mhn-regs.h>

/* memory start and end */
#define MEMORY_START		(0xa0000000)
#define MEMORY_END			(0xb0000000)

#ifndef __ASSEMBLY__

/* generic read/write */

#define readb(a)	(*(volatile u8*)(a))
#define readw(a)	(*(volatile u16*)(a))
#define readl(a)	(*(volatile u32*)(a))

#define writeb(v,a)	(*(volatile u8*)(a)=(v))
#define writew(v,a)	(*(volatile u16*)(a)=(v))
#define	writel(v,a)	(*(volatile u32*)(a)=(v))

#define insb(a,p,l)	({ 			\
	int __i;				\
	for (__i=0; __i<(l); __i++) 		\
		((u8*)(p))[__i]= readb((a)); 	\
})

#define insw(a,p,l)	({ 			\
	int __i;				\
	for (__i=0; __i<(l); __i++) 		\
		((u16*)(p))[__i] = readw((a)); 	\
})

#define insl(a,p,l)	({ 			\
	int __i;				\
	for (__i=0; __i<(l); __i++) 		\
		((u32*)(p))[__i] = readl((a)); 	\
})

#define outsb(a,p,l)	({ 			\
	int __i;				\
	for (__i=0; __i<(l); __i++)	 	\
		writeb(((u8*)(p))[__i],(a)); 	\
})

#define outsw(a,p,l)	({ 			\
	int __i;				\
	for (__i=0; __i<(l); __i++) 		\
		writew(((u16*)(p))[__i],(a)); 	\
})

#define outsl(a,p,l)	({	 		\
	int __i;				\
	for (__i=0; __i<(l); __i++)	 	\
		writel(((u32*)(p))[__i],(a));	\
})
#endif

#endif
